<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/bootstrap.css">
    <style>
        #show {
            background-color: #eeeeee;
            width: 100%;
            height: 200px;
            padding-top: 50px;
            padding-right: 30px;
        }
        #show h1{
            margin-left: 40px;
        }
        .navbar-default .navbar-nav > .active > a{
            background: none;
        }
    </style>
</head>

<body>
    <div id="app">
        <nav class="navbar navbar-default">
            <div class="container-fluid">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <a class="navbar-brand" href="#">Vue</a>
                </div>
                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav">
                        <li class="active">
                            <router-link to="/home" href="#">首页</router-link>
                        </li>
                        <li>
                            <router-link to="/aboutUs" href="#">关于我们</router-link>
                        </li>
                        <li class="dropdown">
                            <router-link to="/account" href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                                aria-expanded="false">账户中心 <span class="caret"></span></router-link>
                            <ul class="dropdown-menu">
                                <router-link to="/account/pwd" href="#">密码</router-link>
                            </ul>
                        </li>
                        <li><router-link to="/login" href="#">登录</router-link></li>
                    </ul>
                </div><!-- /.navbar-collapse -->
            </div><!-- /.container-fluid -->
        </nav>
        <div id="show">
            <!-- 内容展示区域(占位符) -->
            <router-view></router-view>
        </div>
    </div>
    <template id="account">
        <div>
            <h1>账户中心</h1>
            <router-view></router-view>
        </div>
    </template>
</body>
<script src="./js/jquery.min.js"></script>
<script src="./js/bootstrap.js"></script>
<script src="./js/vue.js"></script>
<script src="./js/vue-router.js"></script>
<script>
    // 1.组件
    let Home = Vue.extend({template:"<h1>首页</h1>"});
    let AboutUs = {template:"<h1>关于我们</h1>"};
    let Accountt = {template:"#account"};
    let Login = {template:"<h1>登录</h1>"};

    // 2.配置页面的路径信息(多个)
    let routes = [
        {path:'/home',component:Home},
        {path:'/aboutUs',component:AboutUs},
        {path:'/account',component:Accountt,children:[
                {path:"pwd",component:{template:"<h1>密码</h1>"}},
            ]},
        {path:"/login",component:Login}
    ]   

    // 创建路由对象 VueRouter
    let router = new VueRouter({
        routes
    })

    let vm = new Vue({
        el:"#app",
        // 配置路由
        router
    })
</script>
</html>